<?php
/**
 * View TEST LaFabbrica.org
 * 
 * @author     luigi.pastore (gigi@la-fabbrica.org)
 * @created    21-apr-2011
 * @package    LaFabbrica
 * @copyright  Copyright (c) 2011 Luigi Pastore
 */
?>
<script type="text/javascript">
    //<![CDATA[

    /**
     * Callback function that displays the content.
     *
     * Gets called every time the user clicks on a pagination link.
     *
     * @param {int} page_index New Page index
     * @param {jQuery} jq the container with the pagination links as a jQuery object
     */
    var items_per_page = 10;
    var max_elem = 5;
    
    function pageselectCallback(page_index, jq){
	var max_elem = Math.min((page_index+1) * items_per_page, <?php echo count( $this->locations ) ?>);
                
	$('#locations').empty();
                
	// Iterate through a selection of the content and build an HTML string
	for(var i=page_index*items_per_page;i<max_elem;i++)
	{
	    //		    $('#locations').stop().animate({'margin-left': -(parseInt(20-1))*10},'slow');
	    $('#locations').append($('#hiddenresult tr#location_'+i+'').clone());
	}
		
	// Alterna la classe delle righe
	$("tr:even").addClass('alt');
	$("tr:odd").removeClass('alt');

	$("a.map").click(function() {

	    /* Info Locale */
	    var address = $(this).attr('rel');
	    var title	= $(this).attr('title');
	    
	    Shadowbox.open({
		player:     "html",
		content:    "",
		height:     300,
		width:      500,
		options:    {
		    onFinish: function(item) {

			// Una volta caricata la lista degli elementi aggancia
			// la mappa e fa un Geocode prendendo l'indirizzo
			// dall'href del link
			var myOptions = {
			    zoom: 16,
			    mapTypeId: google.maps.MapTypeId.ROADMAP
			};

			/* Istanzia la mappa */
			var map = new google.maps.Map(document.getElementById(Shadowbox.playerId),myOptions);

			geocoder.geocode( { 'address': address}, function(results, status) {
			    if (status == google.maps.GeocoderStatus.OK) {
				map.setCenter(results[0].geometry.location);
				var marker = new google.maps.Marker({
				    map: map,
				    position: results[0].geometry.location,
				    animation: google.maps.Animation.DROP,
				    title: title
				});
			    } else {
				alert("Geocode fallito: " + status);
			    }
			});		
		    }
		}
	    });
	    return false;
	});

	return false;
    }	
    /** 
     * Initialisation function for pagination
     */
    function initPagination() {
	// count entries inside the hidden content
	var num_entries = jQuery('#hiddenresult tr.result').length;
	// Create content inside pagination element
	$(".paginator").pagination(num_entries, {
	    callback: pageselectCallback,
	    next_text : 'Succ. >',
	    prev_text : '< Prec.',
	    num_display_entries : 0,
	    items_per_page:items_per_page // Show only one item per page
	});
    }
	     
    $(document).ready(function()
    {
	geocoder = new google.maps.Geocoder();
	Shadowbox.init();
	initPagination();
    });

    //]]>
</script>
<!--<script type="text/javascript" src="/js/jquery.fancybox-1.3.4.pack.js"></script>
<link rel="stylesheet" type="text/css" href="/css/jquery.fancybox-1.3.4.css" media="screen" />

<a id="various3" href="/data/login.php">Ajax - passing custom data</a>
<a id="various5" href="#map">Iframe (75% width and height)</a>

    <div id="map">MAp</div>-->
    
    
    
    <?php
/**
 * LAYOUT CON COLONNE AFFIANCATE + BOX INFO + FORM
 */
?>
<script type="text/javascript">
    //<![CDATA[
    $(document).ready(function() {

	
    });
    
    //]]>
</script>
<div class="info">
    <h2>Associa Contatto</h2>
    <div>Per inserire un nuovo post...</div>
    <div>I campi contrassegnati da <span class="req">*</span> sono obbligatori!</div>
</div>
<div class="col2">
    <div id="userTable">
	<table cellspacing="0" class="table" id="detailTableLeft">
	    <caption><h3>User Information</h3></caption>
	    <tfoot>
		<tr><td colspan="2">
			<a class="button" href="/users/">Change User Information</a>
		    </td></tr>
	    </tfoot>
	    <tbody>
		<tr>
		    <th>Name:</th>
		    <td>gigip </td>
		</tr>

		<tr>
		    <th>Company:</th>
		    <td></td>
		</tr>

		<tr>
		    <th>Email:</th>
		    <td>luigipastore@gmail.com</td>
		</tr>

		<tr>
		    <th>Timezone:</th>
		    <td>(+2:00) Eastern Europe, Israel</td>
		</tr>
	    </tbody>
	</table>
    </div>

    <table cellspacing="0" class="table" id="detailTableRight">
	<caption><h3>Account Usage</h3></caption>
	<tfoot>
	    <tr><td colspan="3">
		   			<div id="">
			    <button id="salva" type="submit" name="salva" value="salva" class="button positive">
				<img src="/images/admin/add-new.png" alt="" />Salva ed Esci
			    </button>
			    <button id="salva" type="submit" name="salva" value="salva" class="button negative">
				<img src="/images/admin/cross.png" alt="" />Annulla
			    </button>
			</div>
		</td></tr>
	</tfoot>
	<tbody>
	    <tr>
		<td>
		    <form class="fab" name="contactForm" id="contactForm" action="/admin/contatti/associa" method="post" enctype="multipart/form-data">
			<ul>
			    <li id="errorLi" style="<?php echo $this->errorMsg ? '' : 'display:none' ?>">
				<h3 id="errorMsgLbl">Si Ã¨ verificato un problema durante l'invio del modulo.</h3>
				<p id="errorMsg">
		Di seguito trovi evidenziati gli errori riscontrati.
				</p>
			    </li>

			    <li>
				<label class="desc">Locale</label>
				<div>
				    <span class="input">
					<select class="field select addr" id="user_group_id" name="user_group_id">
					    <?php foreach( $this->clubs as $club ) : ?>
    					    <option value="<?php echo $club['club_id'] ?>"><?php echo $club['club_name'] ?></option>
					    <?php endforeach; ?>
					</select>
				    </span>
				</div>
			    </li>

			    <li>
				<label class="desc">Ruolo</label>
				<div>
				    <span class="input">
					<select class="field select addr" id="user_group_id" name="user_group_id">
					    <?php foreach( $this->roles as $k => $role ) : ?>
    					    <option value="<?php echo $k ?>"><?php echo $role ?></option>
					    <?php endforeach; ?>
					</select>
				    </span>
				</div>
			    </li>

			</ul>
		    </form>
		</td>

	    </tr>
	</tbody>
    </table>
</div>
<br style="clear: both" />


